<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue 数组检测和key</title>
</head>
<body>
<div id="app">

    <template v-for="(user,index) in usersList">
        <ul v-bind:id="index">
            <li>
                <input type="checkbox"/>{{user.username}}</li>
            <li>{{user.password}}</li>
        </ul>
    </template>

    <template>
        <button v-on:click="add">添加一条记录</button>
    </template>
</div>

<script src="../js/vue.js"></script>
<script>

    const message = {
        usersList : [
            {
                username : '张三',
                password : '123456',
            },
            {
                username : '李四',
                password : '123456',
            }
        ]
    };

    //数据冻结, 禁止调试
    //Object.freeze(message)

    const demo = new Vue({
        el: '#app',
        data: message,
        methods: {
            add:function (){
                demo.usersList.push({
                    username: "add",
                    password: "123456",
                })
            }
        },
        computed: {}
    });
</script>
</body>
</html>